/**
 * 表单验证
 * 
 * @param {Object} rules 验证字段的规则
 * @param {Object} messages 验证字段的提示信息
 * 
 */

import basic from '../../../xc/model/basic.js';
var actmodel = new basic();
actmodel.do = "barter_pros"

actmodel.offset = function (that, reset, para, xcsorts) { 
  if(!xcsorts)
  {
    xcsorts=[["id", "desc"], ["modifytime", "desc"]] ;
  } 
  var acturlpara = {};   
  acturlpara["url"] = "entry/wxapp/"+actmodel.do
  if (para) {
    para["op"] = "offset"
  }
  else
  {
    para={}
  }
  
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
} 
actmodel.getorderlist=function(model){
  var app = getApp();
  var data = { "op": "getorderlist", model:JSON.stringify(model)}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      'data': data,
      'method': "post",
      success: function (res) {        
        resolve(res.data.data);
      }
    })
})
}
actmodel.getbasic=function(uid){
  var app = getApp();
  var data = { "op": "getbasic", userid:uid}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      'data': data,
      'method': "post",
      success: function (res) {        
        resolve(res.data.data);
      }
    })
})
}
actmodel.applyform = function (formdata,clubid) {
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': {
        "op": "applyform",
        clubid:clubid, 
        formdata:JSON.stringify(formdata)
      },
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}
actmodel.getmember=function(phone){
  var app = getApp();
  var data = { "op": "getmember", phone:phone}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      'data': data,
      'method': "post",
      success: function (res) {        
        resolve(res.data.data);
      }
    })
})
}
actmodel.transfer=function(data){
  var app = getApp();
  var data = { "op": "transferorder", data: JSON.stringify(data)}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      'data': data,
      'method': "post",
      success: function (res) {        
        resolve(res.data.data);
      }
    })
})
}
actmodel.createorder=function(data){
  var app = getApp();
  var data = { "op": "createorder", data: JSON.stringify(data)}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      'data': data,
      'method': "post",
      success: function (res) {        
        resolve(res.data.data);
      }
    })
})
}
actmodel.queryorder=function(id){
  var app = getApp();
  var data = { "op": "queryorder", id: id}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      'data': data,
      'method': "post",
      success: function (res) {        
        resolve(res.data.data);
      }
    })
})
}
module.exports = actmodel;